/*
 * @Author: MrDotYan 2564217790@qq.com
 * @Date: 2024-09-24 11:38:57
 * @LastEditors: MrDotYan 2564217790@qq.com
 * @LastEditTime: 2024-09-24 11:44:20
 * @FilePath: /webServer/src/validator/notice/notice.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ApiProperty } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { alternatives } from '..';
import { NoticeSchema } from '../../schema';

export class SaveNoticeValidator implements NoticeSchema {
  @ApiProperty({
    type: 'string',
    title: '通知/公告标题',
    example: 'null',
    description: '通知/公告标题',
    required: true,
  })
  @Rule(RuleType.string().required())
  title: string;

  @ApiProperty({
    type: 'string',
    title: '通知/公告内容',
    example: 'null',
    description: '通知/公告内容',
    required: true,
  })
  @Rule(RuleType.string().required())
  context: string;
}

export class EditNoticeValidator implements Partial<NoticeSchema> {
  @ApiProperty({
    type: 'string',
    title: '通知/公告标题',
    example: 'null',
    description: '通知/公告标题',
    required: false,
  })
  @Rule(RuleType.alternatives(alternatives))
  title?: string;

  @ApiProperty({
    type: 'string',
    title: '通知/公告内容',
    example: 'null',
    description: '通知/公告内容',
    required: false,
  })
  @Rule(RuleType.alternatives(alternatives))
  context?: string;
}
